package com.ledim.bean;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.Property;
import org.greenrobot.greendao.annotation.ToOne;
import org.greenrobot.greendao.annotation.Transient;
import org.greenrobot.greendao.annotation.Unique;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.DaoException;
import org.greenrobot.greendao.annotation.NotNull;
import com.ledim.db.dao.DaoSession;
import com.ledim.db.dao.LedimUserBeanDao;
import com.ledim.db.dao.LedimPicBeanDao;

/**
 * Created by ccx on 16/6/22.
 * 用户信息
 */
@Entity(
        //  实体是否激活的标志，激活的实体有更新，删除和刷新的方法
        active = true,
        // 确定数据库中表的名称
        // 表名称默认是实体类的名称
        nameInDb = "USER")
public class LedimUserBean implements Serializable {

    @Property(nameInDb = "Id")
    @Id(autoincrement = true)
    private Long id;

    @SerializedName("id")
    @Unique
    @Property(nameInDb = "user_id")
    public String userId;

    @Property(nameInDb = "username")
    public String username;

    @Property(nameInDb = "nickname")
    public String nickname;
    @Property(nameInDb = "email")
    public String email;
    @Property(nameInDb = "mobile")
    public String mobile;
    @Property(nameInDb = "gender")
    public String gender;

    @Property(nameInDb = "avatar")
    private long avatarId;
    @ToOne(joinProperty = "avatarId")
    public LedimPicBean avatar;

    @Property(nameInDb = "coin")
    public String coin;
    @Property(nameInDb = "status")
    public String status;

    @Property(nameInDb = "max_coin")
    public String max_coin;//所有用户最大金币数

    @Property(nameInDb = "max_power")
    public String max_power;//所有用户最大战斗力

    @Property(nameInDb = "power")
    public String power;//用户战斗力

    @Property(nameInDb = "is_signed")
    public boolean is_signed;//是否签到,true:已签到，false:未签到
    @Transient
    public String letvid;
    @Transient
    public int sign_count;

    @Transient
    public int fan;//粉丝数量
    @Transient
    public int focus;//关注的数量
    @Transient
    public int relation;//关注状态  0：未关注  1：已关注  2：相互关注
    @Transient
    public int role;      //房间角色  0:普通用户 1:超级管理员 2:房主
    @Transient
    public int silent;    //禁言状态  0:未禁言  1:禁言
    @Transient
    public int kick;       //踢出状态  0:未踢出  1:已踢出

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 1942392019)
    public void refresh() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.refresh(this);
    }

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 713229351)
    public void update() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.update(this);
    }

    /**
     * Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}.
     * Entity must attached to an entity context.
     */
    @Generated(hash = 128553479)
    public void delete() {
        if (myDao == null) {
            throw new DaoException("Entity is detached from DAO context");
        }
        myDao.delete(this);
    }

    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 1305627050)
    public void setAvatar(@NotNull LedimPicBean avatar) {
        if (avatar == null) {
            throw new DaoException("To-one property 'avatarId' has not-null constraint; cannot set to-one to null");
        }
        synchronized (this) {
            this.avatar = avatar;
            avatarId = avatar.getId();
            avatar__resolvedKey = avatarId;
        }
    }

    /** To-one relationship, resolved on first access. */
    @Generated(hash = 644335251)
    public LedimPicBean getAvatar() {
        long __key = this.avatarId;
        if (avatar__resolvedKey == null || !avatar__resolvedKey.equals(__key)) {
            final DaoSession daoSession = this.daoSession;
            if (daoSession == null) {
                throw new DaoException("Entity is detached from DAO context");
            }
            LedimPicBeanDao targetDao = daoSession.getLedimPicBeanDao();
            LedimPicBean avatarNew = targetDao.load(__key);
            synchronized (this) {
                avatar = avatarNew;
                avatar__resolvedKey = __key;
            }
        }
        return avatar;
    }

    @Generated(hash = 1907406681)
    private transient Long avatar__resolvedKey;
    /** Used for active entity operations. */
    @Generated(hash = 986518109)
    private transient LedimUserBeanDao myDao;

    /** Used to resolve relations */
    @Generated(hash = 2040040024)
    private transient DaoSession daoSession;

    public boolean getIs_signed() {
        return this.is_signed;
    }

    public void setIs_signed(boolean is_signed) {
        this.is_signed = is_signed;
    }

    public String getPower() {
        return this.power;
    }

    public void setPower(String power) {
        this.power = power;
    }

    public String getMax_power() {
        return this.max_power;
    }

    public void setMax_power(String max_power) {
        this.max_power = max_power;
    }

    public String getMax_coin() {
        return this.max_coin;
    }

    public void setMax_coin(String max_coin) {
        this.max_coin = max_coin;
    }

    public String getStatus() {
        return this.status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getCoin() {
        return this.coin;
    }

    public void setCoin(String coin) {
        this.coin = coin;
    }

    public long getAvatarId() {
        return this.avatarId;
    }

    public void setAvatarId(long avatarId) {
        this.avatarId = avatarId;
    }

    public String getGender() {
        return this.gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public String getMobile() {
        return this.mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public String getEmail() {
        return this.email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getNickname() {
        return this.nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    public String getUsername() {
        return this.username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getUserId() {
        return this.userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public Long getId() {
        return this.id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    /** called by internal mechanisms, do not call yourself. */
    @Generated(hash = 38735016)
    public void __setDaoSession(DaoSession daoSession) {
        this.daoSession = daoSession;
        myDao = daoSession != null ? daoSession.getLedimUserBeanDao() : null;
    }

    @Generated(hash = 82540766)
    public LedimUserBean(Long id, String userId, String username, String nickname, String email,
                         String mobile, String gender, long avatarId, String coin, String status,
                         String max_coin, String max_power, String power, boolean is_signed) {
        this.id = id;
        this.userId = userId;
        this.username = username;
        this.nickname = nickname;
        this.email = email;
        this.mobile = mobile;
        this.gender = gender;
        this.avatarId = avatarId;
        this.coin = coin;
        this.status = status;
        this.max_coin = max_coin;
        this.max_power = max_power;
        this.power = power;
        this.is_signed = is_signed;
    }

    @Generated(hash = 546499428)
    public LedimUserBean() {
    }

}
